\documentclass{article}
\usepackage{graphicx} 
\usepackage{longtable}
\usepackage[usenames]{color}
\usepackage[
naturalnames = true,
colorlinks = true,
linkcolor = Black,
anchorcolor = Black,
citecolor = Black,
menucolor = Black,
urlcolor = Blue
]{hyperref}

\title{Software Carpentry Bootcamp : Regex}
\author{The Hacker Within
\\ \href{mailto:hacker.within.admin@gmail.com}{\texttt{hacker.within.admin@gmail.com}}
\\ \url{http://groups.google.com/group/hacker-within/}
\\ \url{http://code.google.com/p/hacker-within/}}
\date{Day 3 -- January 14, 2009}

\setlength{\parindent}{0em}

\begin{document}
\maketitle

\begin{figure}[htp]
\centering
\includegraphics[height=4in]{regexkcd.eps}
\caption{\url{http://xkcd.com/208/}}
\end{figure}
\newpage
\section{Regular Expressions}
\paragraph{}With inspiration from two neurologists, Stephen Kleene, a 1940s mathemetician developed a formal notation for a logical classification of typeset characters and called them regular sets. Combining elements of these regular sets, he created `regular expressions'. Ken Thompson, a programmer in the late sixties, developed a text editor called \emph{ed} with the ability to search the file for patterns defined with this notation. To search for a pattern within a document in \emph{ed}, the user deploys the command to search \textbf{g}lobally for a \textbf{r}egular \textbf{e}xpression and \textbf{p}rint the modifications. It looked like :g/\emph{regular expression}/p. It would become what is now known as grep.\cite{OReilly}
\paragraph{}Regular expressions are a tool for text matching. We'll use this in conjunction with search and print programs like \emph{grep},\emph{ sed}, and\emph{ awk}, for finding, displaying, editing and doing calculations with information in files. Regular expressions are also useful for network administration tasks and mobility in the shell. The following is a cheat sheat that will help introduce the beginner to the syntax of regular expressions. These helpful descriptions and examples are adapted (when not copied verbatim) from the official perl documentation \cite{perl}, Mastering Regular Expressions from O'Reilly \cite{OReilly}, and from the mozilla developer center\cite{mozilla}.
\paragraph{}Importantly, syntactic use of regular expressions will occasionally vary from tool to tool. Grep, awk, sed, and perl have slightly varying uses of regular expressions, for example, and use of each will require investigation into their man pages. Here we'll introduce standard metacharacters and character class treatments recognizable in most tools. 
\section{Metacharacters and Literal Characters}
As you found in Kyle and Matt's previous lectures, you can occasionally use wildcard characters to find files, pipe input to programs, etc. Recall the asterisk. I'll call it a star from now on, because asterisk is an awkward word. Recall that you can find all the text files in a directory for example by saying ls *.txt, because * means 0 or more of any character. This is because star is a \emph{metacharacter} in the shell. Regular expressions are like a language of metacharacters for the purpose of pattern matching in text files, data, network logs, etc. With the help of command line scripting tools like grep, sed, awk, perl, etc. the user can employ this language of metacharacters to investigate and alter large files, sets of files, and network data from the shell. Similarly, the syntax of regular expressions is often deployable from within text editors like vim.
\newpage
\subsection{\textbf{Basic Regular Expressions:}}
\begin{center}
{\renewcommand{\arraystretch}{2}
\renewcommand{\tabcolsep}{0.26666666cm}
\begin{longtable}{lp{.7\linewidth}}{\bfseries}
Character 	& \raggedright 	Meaning\tabularnewline 
\verb|\|		& \raggedright  Precedes a metacharacter to make it literal or a regular charater to make it a metacharacter. \textbf{Example:} /b/ matches the character 'b'. \verb|/\b/|, matches a word boundary. Similarly /a*/ means match 0 or more ``a''s, but \verb|/a\*/| matches 'a*'.\tabularnewline
. 	 				& \raggedright  Matches any single character except the newline characters: \verb|\n \r \u2028 or \u2029. ([\s\S]| can be used to match any character including newlines.\verb|)|\textbf{Example: } /.n/ matches 'in' and 'an' in ``never cycle in an oil spill'', but not 'never'.\tabularnewline 
\verb|*| 	 				& \raggedright  Matches the preceding item 0 or more times. \textbf{Example:}\verb|/zo*/| matches 'zoooo' in ``He zoooomed'' and 'z' in ``motoguzi.''\tabularnewline 
+ 	 				& \raggedright  Matches the preceding item 1 or more times. Equivalent to \verb|{1,}|.\tabularnewline 
\verb|^| 	 	& \raggedright  Matches beginning of a line. \textbf{Example:}, \verb|/^A/| does not match the 'A' in ``an A'', but does match the first 'A' in the line ``An A.''\tabularnewline 
\verb|$| 	 	& \raggedright  Matches the end of a line. \textbf{Example: } \verb|/t$/| does not match any 't' in ``maseratti\verb|\n|'', but does match the t in ``schwinn supersport\verb|\n|''.\tabularnewline 
\verb|{n}| 				& \raggedright  Where n is a positive integer. Matches exactly n occurrences of the preceding item. \textbf{Example:} \verb|/d{2}/| doesn't match the 'd' in ``Greg Lemond,'' but it matches all of the d's in ``Eddy Merckx,'' and the first two d's in ``Eddddy Merckx.''\tabularnewline 
\verb|{n,}|				& \raggedright  Where n is a positive integer. Matches at least n occurrences of the preceding item. \textbf{Example:} /d{2,} still doesn't match the 'd' in ``Greg Lemond'', but matches all of the d's in ``Eddy'' and in ``Eddddddy.''\tabularnewline 
\verb|{n,m}| 			& \raggedright  Where n and m are positive integers. Matches at least n and at most m occurrences of the preceding item. \textbf{Example:} \verb|/d{1,3}/| matches nothing in ``Greg Lemon'', the 'd' in ``Lemond,'' the first two d's in ``Lemonddd'' and the first three a's in ``Lemondddddddd''. Notice that when matching ``Lemonddddddd'', the match is ``ddd'', even though the original string had more d's in it.\tabularnewline 
? 	 				& \raggedright  Matches the preceding item 0 or 1 time. \textbf{Example: } /e?le?/ matches the 'el' in ``angel'' and the 'le' in ``angle.'' If used immediately after any of the quantifiers *, +, ?, or \verb|{}|, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times). Also used in lookahead assertions, described under (?=), (?!), and (?:) in this table.\tabularnewline 
\verb|/(x/)|& \raggedright  Matches x and remembers the match. These are called capturing parentheses. \textbf{Example: } /(foo)/ matches and remembers 'foo' in ``foo bar.'' The matched substring can be recalled from the resulting array's elements [1], ..., [n] or from the predefined RegExp object's properties $1, ..., $9.\tabularnewline 
(?:x) 			& \raggedright  Matches x but does not remember the match. These are called non-capturing parentheses. The matched substring can not be recalled from the resulting array's elements [1], ..., [n] or from the predefined RegExp object's properties $1, ..., $9.\tabularnewline 
x(?=y) 			& \raggedright  Matches x only if x is followed by y. \textbf{Example: } /Eddy(?=Merckx)/ matches 'Eddy' only if it is followed by 'Merckx'. /Eddy(?=Merckx|Planckaert)/ matches 'Eddy' only if it is followed by 'Merckx' or 'Planckaert'. However, neither 'Merckx' nor 'Planckaert' is part of the match results.\tabularnewline 
x(?!y) 			& \raggedright  Matches x only if x is not followed by y. \textbf{Example: } /\d+(?!\.)/ matches a number only if it is not followed by a decimal point. \tabularnewline 
\verb,x|y, 				& \raggedright  Matches either x or y.\textbf{Example: } \verb,/green|yellow/, matches 'green' in ``green jersey'' and 'yellow' in ``yellow jersey.''
\end{longtable}}
\end{center}

\subsection{\textbf{Character Sets:}}
\begin{center}
{\renewcommand{\arraystretch}{2}
\renewcommand{\tabcolsep}{0.26666666cm}
\begin{longtable}{lp{.7\linewidth}}{\bfseries}
\newline
[{   }]& \raggedright A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen.\textbf{Example: } [abcd] is the same as [a-d]. They match the 'b' in ``brisket'' and the 'c' in ``ache''.\tabularnewline 
\newline
[\^{   }] 	& \raggedright A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen.\textbf{Example: } [\^abc] is the same as [\^a-c]. They initially match 'r' in ``brisket'' and 'h' in ``chop.''\tabularnewline 
\verb|[a-zA-Z0-9]| & \raggedright In the C locale, this matches any ASCII letters or digits.\tabularnewline 
\verb|[[:alpha:]]|	& \raggedright Bracket classes have self explanatory names,  [:alnum:],  [:alpha:],  [:cntrl:], [:digit:],  [:graph:],  [:lower:],  [:print:],  [:punct:], [:space:], [:upper:], and [:xdigit:].  \textbf{Example:} [[:alnum:]] means [0-9A-Za-z]. \tabularnewline 
\end{longtable}}
\end{center}

\subsection{\textbf{Extended Metacharacters:}}
\begin{center}
{\renewcommand{\arraystretch}{2}
\renewcommand{\tabcolsep}{0.26666666cm}
\begin{longtable}{lp{.7\linewidth}}{\bfseries}
\verb|[\b]| 	& \raggedright  Matches a backspace. (Not to be confused with \verb|\b|.)\tabularnewline 
\verb|\b| 		& \raggedright  Matches a word boundary, such as a space. (Not to be confused with [\b].)\textbf{Example: } \verb|/\bn\w/| matches the 'no' in ``noonday''; \verb|/\wy\b/| matches the 'ly' in ``possibly yesterday.'' \tabularnewline 
\verb|\B|			& \raggedright  Matches a non-word boundary.\textbf{Example: } \verb|/\w\Bn/| matches 'on' in ``noonday'', and \verb|/y\B\w/| matches 'ye' in ``possibly yesterday.'' \tabularnewline 
\verb|\cX|		& \raggedright  Where X is a letter from A - Z. Matches a control character in a string.\textbf{Example: } \verb|/\cM/| matches control-M in a string.\tabularnewline 
\verb|\d| 		& \raggedright  Matches a digit character in the basic Latin alphabet. Equivalent to [0-9]. Note: In Firefox 2 and earlier, matches a digit character from any alphabet. \textbf{Example: } /\d/ or /[0-9]/ matches '2' in ``B2 is the suite number.''\tabularnewline 
\verb|\D| 		& \raggedright  Matches any non-digit character in the basic Latin alphabet. Equivalent to [\^0-9]. Note: In Firefox 2 and earlier, all alphabet. ( bug 378738 )\textbf{Example: } \verb|/\D/| or /[\^0-9]/ matches 'B' in ``B2 is the suite number.''\tabularnewline 
\verb|\f| 		& \raggedright  Matches a form-feed.\tabularnewline 
\verb|\n| 		& \raggedright  Matches a linefeed.\tabularnewline 
\verb|\r| 		& \raggedright  Matches a carriage return.\tabularnewline 
\verb|\s| 		& \raggedright  Matches a single white space character, including space, tab, form feed, line feed and other unicode spaces.equivalent\verb|_|s\textbf{Example: } \verb|/\s\w*/| matches ' bar' in ``foo bar.''\tabularnewline 
\verb|\S| 		& \raggedright  Matches a single character other than white space \textbf{Example: } \verb|/\S\w*/| matches 'foo' in ``foo bar.''\tabularnewline 
\verb|\t| 		& \raggedright  Matches a tab.\tabularnewline 
\verb|\v| 		& \raggedright  Matches a vertical tab.\tabularnewline 
\verb|\w| 		& \raggedright  Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9\verb|_|].\textbf{Example: } \verb|/\w/| matches 'a' in ``aardvark,'' '3' in ``\$3.141,'' and 'D' in ``DangerZone.''\tabularnewline 
\verb|\W| 	 	& \raggedright  Matches any character that is not a word character from the basic Latin alphabet. Equivalent to [\verb|^|A-Za-z0-9\verb|_|].\textbf{Example: } \verb|/\W/| or /[\verb|^|\$A-Za-z0-9\verb|_|]/ matches '\%' in ``50\verb|%.|''\tabularnewline 
\verb|\n| 		& \raggedright  Where n is a positive integer. A back reference to the last substring matching the n parenthetical in the regular expression (counting left parentheses).\textbf{Example: } /apple(,)\verb|\sorange\1/| matches 'apple, orange,' in ``apple, orange, cherry, peach.'' A more complete example follows this table.\tabularnewline 
\verb|\0| 	 					& \raggedright  Matches a NUL character. Do not follow this with another digit.\tabularnewline 
\verb|\xhh| 	& \raggedright  Matches the character with the code hh (two hexadecimal digits)\tabularnewline 
\verb|\uhhhh| & \raggedright  Matches the character with the Unicode value hhhh (four hexadecimal digits). \tabularnewline 
\end{longtable}}
\end{center}

\subsection{\textbf{Examples:}}
\begin{center}
{\renewcommand{\arraystretch}{2}
\renewcommand{\tabcolsep}{0.26666666cm}
\begin{longtable}{lp{.7\linewidth}}{\bfseries}
`abcdef'& \raggedright  Matches `abcdef'.\tabularnewline 
`a*b'& \raggedright  Matches zero or more `a's followed by a single `b'. \textbf{Example: } `b' or `aaaaab'.\tabularnewline 
`\verb|a\?b|' & \raggedright Matches `b' or `ab'.\tabularnewline 
`\verb|a\+b\+|' & \raggedright Matches one or more `a's followed by one or more `b's: `ab' is the shortest possible match, but other examples are `aaaab' or `abbbbb' or `aaaaaabbbbbbb'.\tabularnewline 
`.*'\tabularnewline 
`\verb|.\+|' & \raggedright Both match all the characters in a string; however, the first matches every string (including the empty string), while the second matches only strings containing at least one character.\tabularnewline 
`\verb|\^spalunking.*(.*)|' & \raggedright This matches a line starting with `spalunking', followed by an opening and closing parenthesis with any string in them. The `g', `(' and `)' need not be adjacent.\tabularnewline 
`\verb|\^#|' & \raggedright Matches a line beginning with `\verb|#|'.\tabularnewline 
`\verb|\\$|' & \raggedright Matches a line ending with a single backslash. The regexp contains two backslashes for escaping.\tabularnewline 
`\verb|\$|' & \raggedright Matches a string anywhere including single dollar sign, verbatim.\tabularnewline 
`[\verb|\^ tab]\+|' & \raggedright (Here tab stands for a single tab character.) This matches a string of one or more characters, none of which is a space or a tab. Usually this means a word.\tabularnewline 
`\verb|\^\(.*|\verb|\|\verb|)\n\1$|' & \raggedright   Matches two equal substrings separated by a newline.\tabularnewline 
`\verb|.\{9\}A$|' & \raggedright Matches any nine characters followed by an `A'.\tabularnewline 
`\^.\{15\}A' & \raggedright Matches the start of a string that contains any 16 characters, the last of which is an `A'. \tabularnewline 
\end{longtable}}
\end{center}


\section{grep, sed, and awk}
\textbf{Syntax}
\begin{itemize}
\item{\textbf{\emph{grep}} has the basic syntax \verb|grep `pattern' inputfile|. It can be modified with flags, pipes, etc.} Grep grabs matched patterns and prints them.
\item{\textbf{\emph{sed}} has the basic syntax \verb|sed `s/pattern/substitution/ inputfile'|. It can be modified with flags, output files, etc.} Sed combines grep with a substitution command.
\item{\textbf{\emph{awk}} has the basic syntax \verb|awk pattern {action}|. Either pattern or action can be omitted. It can be modified with flags. }
\end{itemize}
\subsection{:g/re/p}
Enter the directory /usr/share/dict. Investigate the document called words. Use wc -l. Use -c.
\begin{center}
{\renewcommand{\arraystretch}{2}
\renewcommand{\tabcolsep}{0.26666666cm}
\begin{longtable}{lp{.7\linewidth}}{\bfseries}
hacker&\raggedright Look for the word hacker in the words document \verb|grep `hacker' words|\tabularnewline
within&\raggedright Look for the word within in the words document \verb|grep `within' words| \tabularnewline
\verb|\|&\raggedright Compare \verb|grep -c `within' words| and \verb|grep -c `\within' words|\tabularnewline
.&\raggedright Compare \verb|grep -c `.ithin' words| to \verb|grep -c `\within' words|.\tabularnewline
*&\raggedright Try \verb|grep -c `.*ithin' words|, etc. \tabularnewline
+&\raggedright Try \verb|grep -c `pre.\+' words| and \verb|grep -c `./+pre./+' words|\tabularnewline
\verb|^|&\raggedright Compare \verb|grep `cat' words| and \verb|grep `^cat' words|\tabularnewline
\$&\raggedright Compare \verb|grep `cat' words| and \verb,grep `cat' words$,. Find blank lines \verb|grep `^$' words|\tabularnewline
\verb|[]|&\raggedright Compare \verb|grep `^[rstu]\+$' words| and \verb|grep `^[r-u]\+$' words|\tabularnewline
\verb|{}|&\raggedright Compare \verb|grep `^[r-u]\{3\}' words| versus \verb|grep `[r-u]\{3,\}'|\tabularnewline
\end{longtable}}
\end{center}
\begin{itemize}
\item{\textbf{Exercises with grep}}\vspace{.5cm}\newline
\textbf{With the words file}
\begin{itemize}
\item{Find all three letter words.}\newline
\item{Find all three letter words involving the letter r.}\newline
\item{Find the words with two consecutive a's.}\newline
\item{Find the words ending in 's}\newline
\item{-r} is the recursive flag. What does that mean?
\item{-c} counts matched lines. Use it.
\item{-i} ignores capitalization. What is an equivalent expression using brackets?
\end{itemize}
\textbf{Relocate to /usr/share/X11.} \verb|less rgb.txt|\newline
\begin{itemize}
\item{Find Milad's favorite color, cadet blue}
\item{Find all the types of red}
\item{Find all the codes of the form \verb|255 ___ 255|}
\item{Find all the colors that end with the letter f}
\item{Explore!}
\end{itemize}
\end{itemize}

\subsection{sed}
Sed is best for editing files. For safety we should try not to change important system files (woe betide he who damages the hex code for peach puff). Let's relocate to the bootcamp/wednesday/regex directory.\newline
\emph{sed} differs from \emph{grep} in many ways, but can duplicate grep as well. Here are some examples of the flexibility of sed.
\begin{itemize}
\item{sed prints the whole file instead of just matched lines.} \newline
That can be annoying. Try \verb|sed 's/al/ul/' wordlist.txt|
\item{You can duplicate grep with sed}\newline
Try \verb|sed -n `s/pattern/&/p' inputfile| \newline
Compare \verb|sed -n `s/ax/&/p' wordlist.txt|\newline
and \verb|grep `ax' wordlist.txt| 
\item{sed is strongest as a tool for substitution}\newline
\verb|sed `s/regex/substitution/' oldfile |\newline
Try to change all the `iller's to `illa's in thriller.\newline
\verb|sed `s/iller/illa/' thriller.txt|\newline
Take note! It only changes the first match in the line.
\item{Specify \textbf{g}lobal substitution to capture all matches}\newline
\verb|sed `s/iller/illa/g' thriller.txt|
\item{sed can save output as a new file.}\newline
\verb|sed `s/regex/substitution/' oldfile > newfile|\newline
\verb|sed `s/iller/illa/' thriller.txt > thriller2.txt|
\item{Or, if you're brave, you can edit in place with the -i flag.}\newline
\verb|sed -i `s/regex/substitution/' oldfile|\newline
\verb|sed -i `s/iller/illa/' thriller.txt|
\item{You can give multiple commands by piping sed output back into sed.}\newline
\verb,sed `s/a/A/' thriller.txt | sed `s/b/B/',\newline
Save time by noticing this is equivalent to the -e flag\newline
\verb|sed -e `s/a/A/' -e `s/b/B/' thriller.txt|\newline
\item{Similarly you can input to sed from grep, echo, awk... }\newline
Try \verb,grep `hat' wordlist.txt | sed `s/at/ut/' ,\newline
Or \verb,echo supercalifragilisticexpialidocious | sed 's/[pg]\+/m/g',
\item{Delete all blank lines in a file of phone numbers using d.}\newline
\verb|sed '/^$/d' phone.txt|
\item{Double space the file.}\newline
Try deleting blank lines and appending carriage returns to each line. \newline
\verb,sed -e '/^$/d' -e 's/^\(.\+\)$/\1\n/' phone.txt,\newline
But there's an easier way. Try G. \newline
\verb,sed -e '/^$/d' -e G phone.txt,\newline
Or even just:\newline
\verb,sed '/^$/d;G' phone.txt,
\item{Reformat phone numbers in phone.txt}\newline
This uses a tool for remembering strings \verb|\(\)|\newline
\verb|sed 's/.*\([0-9]\{3\}\).*\([0-9]\{3\}\).*\([0-9]\{3\}\).*/(\1)\2-\3/' phone.txt|
\item{You can number the lines of a file}\newline
\verb,sed '/./=' wordlist.txt | sed '/./N; s/\n/ /',
\item{Specify a line number to modify}\newline
\verb,sed '4 s/r/R/' wordlist.txt,
\item{Specify a range of line numbers to modify}\newline
\verb|sed 'sed '4,6 s/r/T/' wordlist.txt|
\item{Select lines to modify by pattern matching.}\newline
\verb|sed '/^z/ s/$/zzzzzzzzzz$/' wordlist.txt|\newline
\verb|sed '/wade/,/salt/ s/m/PPPPPPPPPP/' wordlist.txt|
\item{\textbf{Exercises with sed}}\newline
Relocate to the directory /bootcamp/wednesday/regex.
\begin{itemize}
\item{Replace all the instances of `America' in demcon.txt with `Omerica'}\newline
\item{How many times did Obama say `hope' in demcon.txt and announce.txt?}\newline
\item{In all four letter words beginning with `f' with four \verb|*| characters in wordlist.txt}\newline
\item{Delete all the words between Ma and mama in wordlist.txt.}
\item{Write a new file called three.txt containing all words greater than 2 but no more than 4 letters long in wordlist.txt}
\end{itemize}
\end{itemize}

\subsection{awk}
awk is best for manipulating columns of data.\newline
Relocate to the /usr/share/X11 directory.
\begin{itemize}
\item{List matching rows}\newline
\verb|awk `/puff/' rgb.txt|\newline
\verb|awk '/144/' rgb.txt|\newline
\verb|awk '/^.+144/' rgb.txt|\newline
\verb|awk '/^.+ +.+144/' rgb.txt|\newline
\item{Add an action. Dollars indicate columns}\newline
\verb|awk `{print $1$2$3}' rgb.txt|\newline
\verb|awk `/^255/{print $1$2$3}' rgb.txt|\newline
\verb|awk '/^.+ +.+144/{print $1$2$3}' rgb.txt|\newline
\item{Switch column order}\newline
\verb|awk '{print $1," ",$2," ",$2," "$1}' rgb.txt|
\item{Modify just one line}\newline
\verb|awk NR==11'{print $1 $2 $3,"\t",$4}' rgb.txt|
\item{Do some math}\newline
\verb|awk NR==11'{print $1,"+",$2,"+",$3,"=",$1+$2+$3}' rgb.txt|
\item{\textbf{Guided Exercises with awk}}
Relocate to /bootcamp/wednesday/regex. Investigate beercalories.txt and thaifoodcalories.txt.
\begin{itemize}
\item{Investigate the sed script beerscript.sed. What commands are in it? What do you guess these commands will do to beercalories.txt?}
\item{Apply the sed script to the beercalories.txt file}\newline
\verb|sed -f beerscript.sed beercalories.txt|
\item{Pipe} the output of the sed script into awk and multiply calories with carbs.
\verb,sed -f beerscript.sed beercalories.txt | awk `{print $3*$4}',
\item{Print} information for the beers that have a calories$\times$carbs value lower than 1000.\newline
\verb~sed -f beerscript.sed beercalories.txt | awk '$3*$4<1000{print $3*$4," \t ",$1}'~
\item{Now print} just the names of those beers.\newline
\verb~sed -f beerscript.sed beercalories.txt | awk '$3*$4<1000{print $1}'~
\item{Explore thaifoodcalories.txt in a similar manner. Good luck!}
\end{itemize}
\end{itemize}


\begin{thebibliography}{10}
\bibitem{mozilla}Mozilla Developer Center - Regular Expressions. Mozilla. 5 Jan. 2007. $<$\url{https://developer.mozilla.org/en/Core_JavaScript_1.5\_Guide/Regular_Expressions}$>$ 
\bibitem{OReilly}Friedl, J.E. Mastering Regular Expressions. O'Reilly \& Associates. Sebastopol, CA. 2002.
\bibitem{perl}Perl 5.10.0 documentation. Perl. 17 Dec. 2008 $<$\url{http://perdoc.perl.org/perlre/html}$>$. 
\end{thebibliography}
\end{document}
